package Service;

import java.util.ArrayList;
import java.util.List;

import dao.RewardDao;
import pojo.PageBean;
import pojo.Reward;

public class RewardService {
	RewardDao cdao;
	public PageBean<Reward> show(int currentPage,int pageSize) {
		cdao = new RewardDao();
		PageBean<Reward> pb = new PageBean<Reward>();
		pb.setList(cdao.PageData(currentPage, pageSize));
		pb.setTotal(cdao.getTotal());
		int totalPage=(cdao.getTotal()%pageSize==0)?(cdao.getTotal()/pageSize):(cdao.getTotal()/pageSize+1);
		pb.setTotalPage(totalPage);
		pb.setCurrentPage(currentPage);
		pb.setPageSize(pageSize);
		return pb;
	}
	public List<Reward> showRewardByType(int currentPage,int pageSize,int id){
		cdao = new RewardDao();
		List<Reward>list=new ArrayList<Reward>();
		list=cdao.showRewardByType(currentPage, pageSize, id);
		return list;
	}
	public int add(Reward p) {
		cdao=new RewardDao();
		int flag=cdao.add(p);
		return flag;
	}

}
